(function(exports) {
	exports.SimBind = function(options) {
		this.render = function() {
			var el = document.querySelector(this.el);
			var children = el.childNodes;
			if (children && children[1] && children[1].attributes['data-repeat']) {
				var html = '';
				for (var j in this.data) {
					html += this.attachData(this.template, this.data[j]);
				}
				el.innerHTML = html;
			} else
				el.innerHTML = this.attachData(this.template, this.data);


		};

		this.attachData = function(el, data) {
			var fragment = '';
			for (var key in data) {
				var reg = new RegExp('{{' + key + '}}', 'g');
				fragment = (fragment || el).replace(reg, data[key]);
			}
			return fragment;

		};

		Object.defineProperty(this, 'data', {
			get: function() {
				return this._data;
			},
			set: function(val) {
				if (this._data != val) {
					this._data = val;
					this.render();
				}
			}
		});

		if (options && options.el) {
			this.el = options.el;
			this.template = document.querySelector(this.el).innerHTML;
			this.data = options.data;
		}
	}
})(window);